package cn.zd.demo1;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class InitActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Toast.makeText(this,this.getClass().getName(),Toast.LENGTH_LONG).show();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_init);
        Button btn = findViewById(R.id.btn_active_forword_back);
        btn.setOnClickListener(this);
        findViewById(R.id.btn_textview_show).setOnClickListener(this);
        findViewById(R.id.btn_button_show).setOnClickListener(this);
        findViewById(R.id.btn_linearlayout_show).setOnClickListener(this);
        findViewById(R.id.btn_gridlayout_show).setOnClickListener(this);
        findViewById(R.id.btn_relativelayout_show).setOnClickListener(this);
        findViewById(R.id.btn_scrollview_show).setOnClickListener(this);
        findViewById(R.id.btn_imageview_show).setOnClickListener(this);
        findViewById(R.id.btn_imagebutton_show).setOnClickListener(this);
        findViewById(R.id.btn_drawview_show).setOnClickListener(this);
        findViewById(R.id.btn_selector_show).setOnClickListener(this);
        findViewById(R.id.btn_edittext_show).setOnClickListener(this);
        findViewById(R.id.btn_dialog_show).setOnClickListener(this);
        findViewById(R.id.btn_popwindows).setOnClickListener(this);
        findViewById(R.id.btn_adapter_show).setOnClickListener(this);
        findViewById(R.id.btn_listview_show).setOnClickListener(this);
        findViewById(R.id.btn_gridview_show).setOnClickListener(this);
        findViewById(R.id.btn_viewpage_show).setOnClickListener(this);
        findViewById(R.id.btn_fragment_show).setOnClickListener(this);
        findViewById(R.id.btn_active_sharedpreferences).setOnClickListener(this);
        findViewById(R.id.btn_active_sql).setOnClickListener(this);
        findViewById(R.id.btn_room).setOnClickListener(this);
        findViewById(R.id.btn_active_myapplication).setOnClickListener(this);
        findViewById(R.id.btn_active_contentprovider).setOnClickListener(this);
        findViewById(R.id.btn_active_contentobserver).setOnClickListener(this);
        findViewById(R.id.btn_active_permission).setOnClickListener(this);
        findViewById(R.id.btn_active_broadcast).setOnClickListener(this);
        findViewById(R.id.btn_active_screen).setOnClickListener(this);
        findViewById(R.id.btn_active_vide).setOnClickListener(this);
        findViewById(R.id.btn_active_webview).setOnClickListener(this);
        findViewById(R.id.btn_active_post).setOnClickListener(this);
        TextView textView = findViewById(R.id.tv_metadata);
        // 获取元数据
        try {
            ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
            textView.setText("获取到的元数据："+activityInfo.metaData.getString("metaname"));

        } catch (PackageManager.NameNotFoundException e) {
            Log.i("PK","获取元数据出错了！");
        }
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_active_forword_back) {
            Intent intent = new Intent(this, ActivityForwdBackActivity.class);
            startActivity(intent);
        } else if(v.getId() == R.id.btn_textview_show) {
            startActivity(new Intent(this, TextViewsActivity.class));
        }  else if(v.getId() == R.id.btn_button_show) {
            startActivity(new Intent(this, ButtonActivity.class));
        } else if(v.getId() == R.id.btn_linearlayout_show) {
            startActivity(new Intent(this, LinearLayoutActivity.class));
        } else if(v.getId() == R.id.btn_gridlayout_show) {
            startActivity(new Intent(this, GridLayoutActivity.class));
        } else if(v.getId() == R.id.btn_relativelayout_show) {
            startActivity(new Intent(this, RelativeLayoutActivity.class));
        }else if(v.getId() == R.id.btn_scrollview_show) {
            startActivity(new Intent(this, ScrollViewActivity.class));
        }else if(v.getId() == R.id.btn_imageview_show) {
            startActivity(new Intent(this, ImageViewActivity.class));
        }else if(v.getId() == R.id.btn_imagebutton_show) {
            startActivity(new Intent(this, ImageButtonActivity.class));
        }else if(v.getId() == R.id.btn_drawview_show) {
            startActivity(new Intent(this, DrawableActivity.class));
        }else if(v.getId() == R.id.btn_selector_show) {
            startActivity(new Intent(this, SelectorActivity.class));
        }else if(v.getId() == R.id.btn_edittext_show) {
            startActivity(new Intent(this, EdittextActivity.class));
        }else if(v.getId() == R.id.btn_dialog_show) {
            startActivity(new Intent(this, DialogActivity.class));
        }else if(v.getId() == R.id.btn_popwindows) {
            startActivity(new Intent(this, PopWindowActivity.class));
        }else if(v.getId() == R.id.btn_adapter_show) {
            startActivity(new Intent(this, AdapterActivity.class));
        }else if(v.getId() == R.id.btn_listview_show) {
            startActivity(new Intent(this, ListViewActivity.class));
        }else if(v.getId() == R.id.btn_gridview_show) {
            startActivity(new Intent(this, GridViewActivity.class));
        }else if(v.getId() == R.id.btn_viewpage_show) {
            startActivity(new Intent(this, ViewPageActivity.class));
        }else if(v.getId() == R.id.btn_fragment_show) {
            startActivity(new Intent(this, FragmentActivity.class));
        }else if(v.getId() == R.id.btn_active_sharedpreferences) {
            startActivity(new Intent(this, SharedPreferencesActivity.class));
        }else if(v.getId() == R.id.btn_active_sql) {
            startActivity(new Intent(this, SQLiteActivity.class));
        }else if(v.getId() == R.id.btn_room) {
            startActivity(new Intent(this, RoomActivity.class));
        }else if(v.getId() == R.id.btn_active_myapplication) {
            startActivity(new Intent(this, MyApplicationActivity.class));
        }else if(v.getId() == R.id.btn_active_contentprovider) {
            startActivity(new Intent(this, MyContentProviderActivity.class));
        }else if(v.getId() == R.id.btn_active_contentobserver) {
            startActivity(new Intent(this, MyContentObserverActivity.class));
        }else if(v.getId() == R.id.btn_active_permission) {
            startActivity(new Intent(this, PermissionActivity.class));
        }else if(v.getId() == R.id.btn_active_broadcast) {
            startActivity(new Intent(this, BroadcastActivity.class));
        }else if(v.getId() == R.id.btn_active_screen) {
            startActivity(new Intent(this, ScreenActivity.class));
        }else if(v.getId() == R.id.btn_active_vide) {
            startActivity(new Intent(this, VideoActivity.class));
        }else if(v.getId() == R.id.btn_active_webview) {
            startActivity(new Intent(this, WebViewActivity.class));
        }else if(v.getId() == R.id.btn_active_post) {
            startActivity(new Intent(this, PostActivity.class));
        }
    }
}